package v3.config;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import v3.common.exception.ApiException;
import v3.common.exception.BadRequestException;

@ControllerAdvice
public class ExceptionHandleConfig {
    @ExceptionHandler(BadRequestException.class)

    public ResponseEntity getHandle(BadRequestException e){
        return  new ResponseEntity(e.getMessage(), HttpStatus.BAD_REQUEST);
    }

    @ExceptionHandler(ApiException.class)
    public ResponseEntity getHandle(ApiException e){
        return  new ResponseEntity(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
    }

}
